#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'xdao07'

import base64
import gitlab


url = 'http://192.168.10.112'
token = 'q8sY2x6TF8eKWYy8RAB7'


# 登录
gl = gitlab.Gitlab(url, token)

# 获取项目
project = gl.projects.get('ZEP-BACKEND/ZEP-BACKEND-JAVA')
# 获取javademo目录下文件列表，版本为master
items = project.repository_tree(path='javademo', ref='master')


def get_all_files(path=None, ref='master'):
    items = project.repository_tree(path=path, ref=ref)
    for item in items:
        if item['mode'] == '040000':
            # 调用递归，实现目录递归输出
            get_all_files(item['path'], ref)
        if item['mode'] == '100644':
            print("===({})===".format(item['path']))


def get_file_content(path=None, ref='master'):
    item = project.repository_tree(path, ref=ref)
    pass


if __name__ == '__main__':
    get_all_files(path='javademo', ref='master')
